package com.ego.order.config;

import com.ego.order.properties.PayProperties;
import com.github.wxpay.sdk.IWXPayDomain;
import com.github.wxpay.sdk.WXPayConfig;
import lombok.Data;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.InputStream;

/**
 * @author Ares
 * @date 2020-12-12
 */
@Data
@Component
@EnableConfigurationProperties(PayProperties.class)
public class WXPayConfiguration extends WXPayConfig {
    @Resource
    private PayProperties payProperties;

    @Override
    public String getAppID() {
        return payProperties.getAppID();
    }

    @Override
    public String getMchID() {
        return payProperties.getMchID();
    }

    @Override
    public String getKey() {
        return payProperties.getKey();
    }

    @Override
    public InputStream getCertStream() {
        return null;
    }

    @Override
    public IWXPayDomain getWXPayDomain() {
        return new IWXPayDomain() {
            @Override
            public void report(String s, long l, Exception e) {

            }

            @Override
            public DomainInfo getDomain(WXPayConfig wxPayConfig) {
                return new DomainInfo("api.mch.weixin.qq.com",true);
            }
        };
    }

}
